// 文章表
import { Entity, Column, Index } from 'typeorm';
import { CommonEntity } from './common.entity'
// posts：帖子表也可以叫文章表
@Entity('posts')
export class PostEntity extends CommonEntity {
    @Index('posts_title_index') //索引
    @Column({
      type: 'varchar',
      nullable: false,
      length: 50,
      name: 'title',
      comment: '标题',
    })
    title: string;

    @Column({
      type: 'varchar',
      nullable: true,
      length: '200',
      name: 'img_url',
      comment: '文章封面图',
    })
    imgUrl: string;

    @Column({
      type: 'text',
      nullable: true,
      name: 'content',
      comment: '内容',
    })
    content: string;

    @Column({
      type: 'int',
      nullable: true,
      name: 'category_id',
      comment: '分类id',
    })
    categoryId: number;

    @Column({
      type: 'varchar',
      nullable: true,
      length: '200',
      name: 'tag_ids',
      comment: '标签id集合',
    })
    tagIds: string;
  
    @Column({
      type: 'int',
      name: 'look_count',
      default: () => 0,
      comment: '浏览数',
    })
    lookCount: number;
  
    @Column({
      type: 'int',
      name: 'like_count',
      default: () => 0,
      comment: '点赞数',
    })
    likeCount: number;
  
    @Column({
      type: 'int',
      name: 'collect_count',
      default: () => 0,
      comment: '收藏数',
    })
    collectCount: number;
  
    @Column({
      type: 'int',
      name: 'user_id',
      comment: '用户id',
    })
    userId: number;
}